package fast.mvc;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

public class StatsTableModel implements TableModel {
	
	Map<String,Double> statsMap = null;
	
	public StatsTableModel(Map<String, Double> map){
		statsMap = map;
	}
	
	@Override
	public void addTableModelListener(TableModelListener l) {
		//
	}

	@Override
	public Class<?> getColumnClass(int columnIndex) {
		switch(columnIndex){
			case 0: return String.class;
			case 1: return Double.class;
            default: break;
        }
		return null;
	}

	@Override
	public int getColumnCount() {
		return 2;
	}

	@Override
	public String getColumnName(int columnIndex) {
		switch(columnIndex)
        {
            case 0: return "Stat";
            case 1: return "EP Value";
            default: break;
        }
        return null;
	}

	@Override
	public int getRowCount(){
		return statsMap.size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		switch(columnIndex) {
            case 0:
            	Set<String> set = statsMap.keySet();
            	Object[] setArray = set.toArray();
            	String s = (String) setArray[rowIndex];
            	return s;
            case 1: 
            	Collection<Double> collection = statsMap.values();
            	Object[] collectionArray = collection.toArray();
            	Double d = (Double) collectionArray[rowIndex];
            	return d;
            default: 
            	break;
        }
        return null;
	}

	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return false;
	}

	@Override
	public void removeTableModelListener(TableModelListener l) {
		//
	}

	@Override
	public void setValueAt(Object value, int rowIndex, int columnIndex) {
		//		
	}

}
